FROM golang:alpine as builder

RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates && go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct

WORKDIR /go/src/app

RUN go get github.com/cespare/reflex

COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

RUN go build -o ./run .

FROM alpine:latest
RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates 
WORKDIR /root/

#Copy executable from builder
COPY --from=builder /go/src/app/run .

EXPOSE 8080
CMD ["./run"]